package com.example.health.controller;

import com.example.health.common.Result;
import com.example.health.entity.CheckFiles;
import com.example.health.service.CheckFilesService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 健康档案控制层
 */
@RestController
@RequestMapping("/checkFiles")
public class CheckFilesController extends BaseController {

    @Resource
    private CheckFilesService checkFilesService;

    /**
     * 分页查询健康档案列表
     * 每页显示5条
     */
    @GetMapping
    public Result<?> findPage (@RequestParam(defaultValue = "1") Integer pageNum,
                               @RequestParam(defaultValue = "5") Integer pageSize,
                               @RequestParam(defaultValue = "") String search,
                               @RequestParam(defaultValue = "") Integer userId){
        return checkFilesService.findCheckFilesPage(pageNum, pageSize, search, userId);
    }

    /**
     * 获取健康档案列表
     */
    @PostMapping("/getMealList")
    public Result<?> getMealList (CheckFiles checkFiles){
        return checkFilesService.getMealList(checkFiles);
    }
    /**
     * 新增健康档案
     * @param checkFiles
     * @return
     */
    @PostMapping
    public Result<?> save (@RequestBody CheckFiles checkFiles){
        return checkFilesService.addCheckFiles(checkFiles);
    }

    /**
     * 修改健康档案
     * @param checkFiles
     * @return
     */
    @PutMapping
    public Result<?> update (@RequestBody CheckFiles checkFiles){
        return checkFilesService.update(checkFiles);
    }

    /**
     * 删除健康档案
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public Result<?> delete (@PathVariable Integer id){
        return checkFilesService.delete(id);
    }

















}
